package top.program.common.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    private static Calendar calendar = Calendar.getInstance();
    /**
     *@Author xcl
     *@Date 2017/10/17 0:58
     *@Description 获得当前周几
     */
    public static int getWake(){
        calendar.setTime(new Date());
        int week = calendar.get(Calendar.DAY_OF_WEEK) -1;
        if(week<0) week = 7;
        return week;
    }

    /**
     *@Author xcl
     *@Date 2017/10/17 1:02
     *@Description 计算时间差 分钟数
     */
    public static int getMunite(Date startDate,Date endDate){
        long startlon = startDate.getTime();
        long endlon = endDate.getTime();
        int munite = (int) (endlon-startlon) / (1000*60);
        return munite;
    }
    /**
     *@Author xcl
     *@Date 2017/10/17 3:41
     *@Description 传入小时分钟 获得当天该小时该分钟的日期
     */
    public static Date getDate(int hour,int minite){
        calendar.set(Calendar.HOUR_OF_DAY,hour);
        calendar.set(Calendar.MINUTE,minite);
        return calendar.getTime();
    }

}
